/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.telsoft.util;

/**
 *
 * @author nguyenthang
 */
import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.NodeSelectEvent;
import org.primefaces.model.DefaultTreeNode;
import org.primefaces.model.TreeNode;

@ManagedBean(name = "left_admin")
@SessionScoped
public class leftProcessAdmin implements Serializable {

    private TreeNode root;
    private TreeNode selectNode;
    private TreeNode Lib;
    private TreeNode Doc;
    private TreeNode Docchild;
    private TreeNode component;
    private TreeNode Composite;
    private TreeNode Template;
    private String path;
    public leftProcessAdmin() {
        root = new DefaultTreeNode(root, null);
        Lib = new DefaultTreeNode("Librarys Management", root);
        Doc = new DefaultTreeNode("Documents Management", root);
        Docchild = new DefaultTreeNode("Documents Management", Doc);
        component = new DefaultTreeNode("Components", Lib);
        Composite = new DefaultTreeNode("Composites", Lib);
        Template = new DefaultTreeNode("Templates", Lib);
    }

    public TreeNode getRoot() {
        return root;
    }

    public void setRoot(TreeNode root) {
        this.root = root;
    }
    public void onNodeSelect(NodeSelectEvent event) {  
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Selected", event.getTreeNode().toString());  
  
        FacesContext.getCurrentInstance().addMessage(null, message);  
    }  

    public void setSelectNode(TreeNode selectNode) {
        this.selectNode = selectNode;
    }

    public TreeNode getSelectNode() {
        return selectNode;
    }
    public void navigator(){
        if (selectNode.equals(component)){
            path = "/usercontrols/center/centeradmin.xhtml";
        }
    }

    public TreeNode getLib() {
        return Lib;
    }

    public TreeNode getDoc() {
        return Doc;
    }

    public TreeNode getDocchild() {
        return Docchild;
    }

    public TreeNode getComponent() {
        return component;
    }

    public TreeNode getComposite() {
        return Composite;
    }

    public TreeNode getTemplate() {
        return Template;
    }

    public String getPath() {
        return path;
    }

    public void setLib(TreeNode Lib) {
        this.Lib = Lib;
    }

    public void setDoc(TreeNode Doc) {
        this.Doc = Doc;
    }

    public void setDocchild(TreeNode Docchild) {
        this.Docchild = Docchild;
    }

    public void setComponent(TreeNode component) {
        this.component = component;
    }

    public void setComposite(TreeNode Composite) {
        this.Composite = Composite;
    }

    public void setTemplate(TreeNode Template) {
        this.Template = Template;
    }

    public void setPath(String path) {
        this.path = path;
    }
}
